package com.sgb.kjwl.view.ui.activity.self.logistics;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.amap.api.maps.UiSettings;
import com.google.android.material.bottomsheet.BottomSheetBehavior;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.AppActivityQuotedThirdBinding;
import com.sgb.kjwl.model.entity.self.OrderQuoteEntity;
import com.sgb.kjwl.model.entity.transport.OwnerGoodsDetailInfo;
import com.sgb.kjwl.utils.DisplayUtil;
import com.sgb.kjwl.utils.LogisticsPermissionHelper;
import com.sgb.kjwl.utils.NumberUtil;
import com.swgk.core.base.aroute.AppRouteConstant;
import com.swgk.core.util.UserOperating;
import com.sgb.kjwl.view.ui.activity.MainActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.activity.transport.InquireByLetterActvity;
import com.sgb.kjwl.view.ui.adapter.self.logistics.OfferOwnerAdapter2;
import com.sgb.kjwl.view.widget.transport.IconExplainDialog;
import com.sgb.kjwl.view.widget.transport.QuickMenuPopWindow;
import com.sgb.kjwl.view.widget.transport.QuotedDetailPopWindow;
import com.sgb.kjwl.viewmodel.self.logistics.QuotedThirdModel;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.util.ResolutionUtil;
import com.swgk.core.util.StringUtil;

import java.util.List;

/**
 * Describe:    报价单位 —— 第三方视角（竞价货源）
 * Author:  yangLei
 * Date:    2021/8/25
 */
@Route(path = AppRouteConstant.WuLui.ROUTER_PATH_QUOTE_THIRD_ACTIVITY)
public class QuotedThirdActivity extends AppActivity implements QuickMenuPopWindow.MenuClickResult {

    public QuotedThirdModel viewModel;
    private AppActivityQuotedThirdBinding mBinding;

    //列表数据适配器
    private OfferOwnerAdapter2 listAdapter;
    private AMap aMap;    //地图控制器
    private MapView mapView;    //高德3DMap  地图显示View

    private String goodsNo;

    private BottomSheetBehavior sheetBehavior;
    private int peekHeight = 215;
    //路径信息加载显示完成
    private boolean routeAddressCompleted = false;
    //货物类型信息加载显示完成
    private boolean goodsDetailsCompleted = false;
    private OwnerGoodsDetailInfo sourceDetails;

    private QuotedDetailPopWindow quotedDetailPop;
    private QuickMenuPopWindow menuPop;//快捷菜单弹窗
    private IconExplainDialog iconExplainDialog;//图标说明弹窗
    private boolean isTakeOrders = false;//是否是接单

    public static void start(Context context, String sourceNo) {
        Intent intent = new Intent(context, QuotedThirdActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.putExtra("no", sourceNo);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (mapView != null)
            mapView.onCreate(savedInstanceState);
    }

    @Override
    protected void initView() {
        goodsNo = getIntent().getStringExtra("no");
        mBinding = DataBindingUtil.setContentView(QuotedThirdActivity.this, R.layout.app_activity_quoted_third);
        sheetBehavior = BottomSheetBehavior.from(mBinding.layoutBehavior);
        viewModel = new ViewModelProvider(this).get(QuotedThirdModel.class);
        mapView = mBinding.mapView;
        initMap();
        initEvent();
        initPop();
        initList();
        RequestSourceInfo();
    }

    private void RequestSourceInfo() {
        if (!TextUtils.isEmpty(goodsNo)) {
            viewModel.getOwnerGoodsDetailInfo(this, goodsNo);
        } else {
            finish();
        }
    }

    private void initList() {
        //地图页列表初始化
        if (listAdapter == null)
            listAdapter = new OfferOwnerAdapter2(this, null, true);
        DividerItemDecoration divider2 = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
        divider2.setDrawable(ContextCompat.getDrawable(this, R.drawable.shape_list_divider_10dp));
        mBinding.list.addItemDecoration(divider2);
        LinearLayoutManager layoutManager2 = new LinearLayoutManager(this);
        mBinding.list.setLayoutManager(layoutManager2);
        mBinding.list.setAdapter(listAdapter);
        mBinding.list.setLoadingMoreEnabled(false);
        mBinding.list.setPullRefreshEnabled(false);
        mBinding.smartRefresh.setEnableRefresh(false);

        mBinding.smartRefresh.setOnLoadMoreListener(refreshLayout -> viewModel.getOfferOwnerList(this, true, sourceDetails));

        listAdapter.setOnTabClickListener(new OfferOwnerAdapter2.OnTabClickListener() {
            @Override
            public void onAgreeClick(OrderQuoteEntity entity) {
                viewModel.agreeOffer(QuotedThirdActivity.this, entity.getGoodsOfferNo(), entity.getSourceNo());
            }

            @Override
            public void onChat(String account) {
                // TODO IM功能目前需要全部去掉，此处需要后期IM迁移完成后完善
                buildSingleTalking(account);
            }
        });
        listAdapter.setOnItemClick(new AdapterOnItemClick<OrderQuoteEntity>() {
            @Override
            public void onItemClick(OrderQuoteEntity orderQuoteEntity, int position) {
                if (orderQuoteEntity != null)
                    showOfferUserInfo(orderQuoteEntity);
            }
        });
    }

    private void initPop() {
        if (menuPop == null) {
            menuPop = new QuickMenuPopWindow(this, 0);
        }
        menuPop.setClickResult(this::onResult);
    }

    private void initEvent() {
        mBinding.setOnClick(this);
        mBinding.include.ivBack.setOnClickListener(this::onClick);
        mBinding.include.rightImageView.setImageResource(R.mipmap.icon_three_point_white);
        mBinding.include.rightImageView.setOnClickListener(this::onClick);

        viewModel.detailsLiveData.observe(this, ownerGoodsDetailInfo -> setDetail(ownerGoodsDetailInfo));
        viewModel.ldCurrOffer.observe(this, new Observer<Integer>() {
            @Override
            public void onChanged(Integer integer) {
                if (integer != null) {
                    if (integer >= 0 && viewModel.getValidBeans().size() > integer) {
                        showOfferUserInfo(viewModel.getValidBeans().get(integer));
                    }
                }
            }
        });

        //底部弹窗视图
        sheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
            @Override
            public void onStateChanged(@NonNull View bottomSheet, int newState) {
                switch (newState) {
                    case BottomSheetBehavior.STATE_COLLAPSED:
                        //折叠状态
                        mBinding.arrowsIv.setImageResource(R.mipmap.icon_ex_lay_up);
                        mBinding.slideAlterInfo.setVisibility(View.VISIBLE);
                        mBinding.scrollView.smoothScrollTo(0, 0);
                        break;

                    case BottomSheetBehavior.STATE_DRAGGING:
                        //拖拽状态
                    case BottomSheetBehavior.STATE_EXPANDED:
                        //完全展开
                        mBinding.arrowsIv.setImageResource(R.mipmap.icon_ex_lay_down);
                        mBinding.slideAlterInfo.setVisibility(View.GONE);
                        break;
                    case BottomSheetBehavior.STATE_HIDDEN:
                        //隐藏状态
                    case BottomSheetBehavior.STATE_SETTLING:
                        //脱离手指自由滑动状态
                        mBinding.arrowsIv.setImageResource(R.mipmap.icon_ex_lay_up);
                        break;
                }
            }

            @Override
            public void onSlide(@NonNull View bottomSheet, float slideOffset) {

            }
        });

        viewModel.setUserInfo.observe(this, userData -> {
            if (userData == null) {
                VerificationCodeLoginActivity.start(this);
                return;
            }
            if (isTakeOrders) {
                LogisticsPermissionHelper.getInstance().checkPermissionToQuoteOrder(
                        this, sourceDetails.getNo(), sourceDetails.getTerminal(), sourceDetails.getMessagePrice()
                );
            } else {
                LogisticsPermissionHelper.getInstance().checkPermissionToQuote(
                        this, sourceDetails.getNo(), sourceDetails.getTerminal(), sourceDetails.getMessagePrice()
                );
            }
        });
    }

    /**
     * 根据不同身份展示报价方信息
     *
     * @param entity
     */
    private void showOfferUserInfo(OrderQuoteEntity entity) {
        if (sheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
            sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        }

        if (quotedDetailPop == null) {
            quotedDetailPop = new QuotedDetailPopWindow(this);
            quotedDetailPop.setOnDismissListener(() -> {
                mBinding.popBg.setVisibility(View.GONE);
                viewModel.resetMarkersSmall();
            });
        }
        quotedDetailPop.setOfferEntity(entity);
        quotedDetailPop.showDownPopwindow(mBinding.iconExplainPop, false);
        mBinding.popBg.setVisibility(View.VISIBLE);
    }

    @Override
    public void onMultiClick(View v) {
        switch (v.getId()) {
            case R.id.offer_btn://报价
                isTakeOrders = false;
                viewModel.getLogisticsPermissions(this);
                break;

            case R.id.receive_order://接单
                isTakeOrders = true;
                viewModel.getLogisticsPermissions(this);
                break;
        }
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;

            case R.id.right_image_view:
                if (menuPop != null) {
                    menuPop.showAsDropDown(mBinding.include.rightImageView, 0, -40);
                }
                break;

            case R.id.skip_more://跳图查竞价货运
                Intent intent = new Intent();
                intent.putExtra("showPage", "FRAGMENT_TUCHA");
                intent.putExtra("position", "2");
                MainActivity.start(this, intent);
                finish();
                break;

            case R.id.icon_explain_pop://图标说明
                if (iconExplainDialog == null)
                    iconExplainDialog = IconExplainDialog.newInstance(this, 0);
                iconExplainDialog.show();
                break;

            case R.id.source_info_bar:
                break;

            case R.id.arrows_iv_bar:
                if (sheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
                    sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                } else {
                    mBinding.slideAlterInfo.setVisibility(View.GONE);
                    sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                }
                break;

            case R.id.ll_call_contact://电话联系
                if (sourceDetails != null && !TextUtils.isEmpty(sourceDetails.getConnectionPhone())) {
                    new RoundDialog.Builder(this)
                            .title("确认呼叫")
                            .content(sourceDetails.getConnectionPhone())
                            .confirm("确定")
                            .cancel("取消")
                            .cancelable(false)
                            .confirmCallback(on -> {
                                Intent intent2 = new Intent(Intent.ACTION_DIAL);
                                Uri data = Uri.parse("tel:" + sourceDetails.getConnectionPhone());
                                intent2.setData(data);
                                startActivity(intent2);
                            }).show();
                }
                break;
            case R.id.ll_online://交流
                if (!UserOperating.getInstance().isLogged()) {
                    VerificationCodeLoginActivity.start(this);
                } else if (sourceDetails != null) {
                    // TODO IM功能目前需要全部去掉，此处需要后期IM迁移完成后完善
                    if (!TextUtils.isEmpty(sourceDetails.getContrctsImAccount())){
                        buildSingleTalking(sourceDetails.getContrctsImAccount());
                    }else {
                        if (!TextUtils.isEmpty(sourceDetails.getImAccount())){
                            buildSingleTalking(sourceDetails.getImAccount());
                        }
                    }
                }
                break;

            case R.id.letter_lay:
                if (!UserOperating.getInstance().isLogged()) {
                    VerificationCodeLoginActivity.start(this);
                } else {
                    if (sourceDetails.getPattern().equals("1")) {
                        InquireByLetterActvity.start(this, 1, sourceDetails.getUsername(), sourceDetails.getUserNo(), sourceDetails.getNo(), sourceDetails.getCityName() + "\u3000" + sourceDetails.getDistrictName() + "->" + sourceDetails.getDestCityName() + "\u3000" + sourceDetails.getDestCityName());
                    } else {
                        InquireByLetterActvity.start(this, 0, sourceDetails.getUsername(), sourceDetails.getUserNo(), sourceDetails.getNo(), sourceDetails.getCityName() + "\u3000" + sourceDetails.getDistrictName() + "->" + sourceDetails.getDestCityName() + "\u3000" + sourceDetails.getDestCityName());
                    }
                }
                break;

            case R.id.invite_lay://邀请
                if (!UserOperating.getInstance().isLogged()) {
                    VerificationCodeLoginActivity.start(this);
                } else if (sourceDetails != null) {
                    switch (sourceDetails.getTerminal()) {
                        case 1:
                            if (!TextUtils.isEmpty(sourceDetails.getCompanyNo())) {
                                LogisticsPermissionHelper.getInstance().checkPermissionToInvite(this, sourceDetails.getCompanyNo(), 1);
                            }
                            break;

                        case 2:
                            if (!TextUtils.isEmpty(sourceDetails.getTeamNo())) {
                                LogisticsPermissionHelper.getInstance().checkPermissionToInvite(this, sourceDetails.getTeamNo(), 2);
                            }
                            break;

                        case 3:
                            if (!TextUtils.isEmpty(sourceDetails.getUserNo())) {
                                LogisticsPermissionHelper.getInstance().checkPermissionToInvite(this, sourceDetails.getUserNo(), 0);
                            }
                            break;

                        default:
                            break;
                    }
                }
                break;
        }
    }

    /**
     * 显示货源相关信息
     *
     * @param sourceDetail
     */
    public void setDetail(OwnerGoodsDetailInfo sourceDetail) {
        if (sourceDetail == null)
            return;
        //每次更新货源信息，需要重置高度，重新计算
        peekHeight = 215;
        routeAddressCompleted = false;
        goodsDetailsCompleted = false;

        mBinding.include.titleView.setText(sourceDetail.getCityName() + " " + sourceDetail.getDistrictName()
                + " -> " + sourceDetail.getDestCityName() + " " + sourceDetail.getDestDistrictName() + "货运项目");
        viewModel.addAllMarkers(this, 0);

        ///////////////////////货源信息
        this.sourceDetails = sourceDetail;
        viewModel.getOfferOwnerList(this, false, sourceDetails);
        //发货起始地
        String addStr = "";
        if (!TextUtils.isEmpty(sourceDetail.getCityName())) {
            addStr += sourceDetail.getCityName() + " ";
        }
        if (!TextUtils.isEmpty(sourceDetail.getDistrictName())) {
            addStr += sourceDetail.getDistrictName() + " → ";
        } else {
            if (!TextUtils.isEmpty(sourceDetail.getCityName()))
                addStr += " → ";
        }
        if (!TextUtils.isEmpty(sourceDetail.getDestCityName())) {
            addStr += sourceDetail.getDestCityName() + " ";
        }
        if (!TextUtils.isEmpty(sourceDetail.getDestDistrictName())) {
            addStr += sourceDetail.getDestDistrictName();
        }
        mBinding.routeAddress.setText(addStr);

        //根据地址信息高度动态改变 BottomSheetBehavior 的 PeekHeight(探出高度)
        mBinding.routeAddress.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                int lineCount = mBinding.routeAddress.getLineCount();
                if (lineCount > 1) {
                    peekHeight += 20;
                }
                mBinding.routeAddress.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                routeAddressCompleted = true;
                setPeekHeight(peekHeight);
            }
        });

        //根据货物信息高度动态改变 BottomSheetBehavior 的 PeekHeight(探出高度)
        mBinding.goodsDetails.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                int lineCount = mBinding.goodsDetails.getLineCount();
                if (lineCount > 1) {
                    peekHeight += 16;
                }
                mBinding.goodsDetails.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                goodsDetailsCompleted = true;
                setPeekHeight(peekHeight);
            }
        });

        //运程
        if (sourceDetail.getPlace() != null && !TextUtils.isEmpty(sourceDetail.getPlace().getTotalDistance())) {
            if (Double.valueOf(sourceDetail.getPlace().getTotalDistance()) < 1000) {
                mBinding.haul.setText("运程：1km以内");
            } else {
                mBinding.haul.setText(String.format("运程：约%skm", StringUtil.fromatUpDistance(sourceDetail.getPlace().getTotalDistance()) + ""));
            }
        }

        //货物信息
        String goodsInfo = "";
        if (!TextUtils.isEmpty(sourceDetail.getGoodsTypesName())) {
            goodsInfo += sourceDetail.getGoodsTypesName() + " ";
        }
        if (!TextUtils.isEmpty(sourceDetail.getWeight())) {
            goodsInfo += NumberUtil.trim0(sourceDetail.getWeight()) + "吨 ";
        }
        if (!TextUtils.isEmpty(sourceDetail.getVolume())) {
            goodsInfo += NumberUtil.trim0(sourceDetail.getVolume()) + "方";
        }
        if (!TextUtils.isEmpty(goodsInfo)) {
            mBinding.goodsDetails.setText(goodsInfo);
        }

        //价格信息
        if (!TextUtils.isEmpty(sourceDetail.getFreight())) {
            mBinding.freightUnit.setText(NumberUtil.trim0(sourceDetail.getFreight()) + sourceDetail.getFreightUnit());
        } else {
            mBinding.freightUnit.setText("/");
        }
        if (!TextUtils.isEmpty(sourceDetail.getAllFreight())) {
            mBinding.freight.setText(NumberUtil.trim0(sourceDetail.getAllFreight()) + "元");
        } else {
            mBinding.freight.setText("/");
        }

        mBinding.mapLay.setVisibility(View.VISIBLE);
    }

    /**
     * 刷新数据显示
     *
     * @param list
     * @param total
     * @param isMore
     */
    public void showOfferOwner(List<OrderQuoteEntity> list, int total, boolean isMore) {
        mBinding.smartRefresh.finishLoadMore();
        mBinding.smartRefresh.finishRefresh();
        refreshListInfo(total, isMore);
        if (list == null) {
            return;
        }
        if (isMore) {
            mBinding.list.loadMoreComplete();
            if (list.size() != 0) {
                listAdapter.addDatas(list);
            }
        } else {
            mBinding.list.refreshComplete();
            if (list.size() == 0) {
                mBinding.emptyOfferLay.setVisibility(View.VISIBLE);
                mBinding.list.setVisibility(View.GONE);
            } else {
                mBinding.emptyOfferLay.setVisibility(View.GONE);
                mBinding.list.setVisibility(View.VISIBLE);
            }
            listAdapter.setDatas(list);
        }
        viewModel.addAllMarkers(this, 1);
    }

    /**
     * 根据数据条数刷新列表信息
     *
     * @param total
     * @param isMore
     */
    private void refreshListInfo(int total, boolean isMore) {
        if (total > 0) {
            mBinding.slideAlterInfo.setText(String.format("当前报价共%d人报价，向上滑动查看当前报价信息", total));
            mBinding.offerNum.setText(String.format("车主报价（%d）", total));
            mBinding.list.setVisibility(View.VISIBLE);
            mBinding.emptyOfferLay.setVisibility(View.GONE);
            setHeight(555);
        } else if (!isMore) {
            mBinding.slideAlterInfo.setText(String.format("当前报价共%d人报价，向上滑动查看当前报价信息", 0));
            mBinding.offerNum.setText(String.format("车主报价（%d）", 0));
            mBinding.list.setVisibility(View.GONE);
            mBinding.emptyOfferLay.setVisibility(View.VISIBLE);
            setHeight(400);
        }
    }

    /**
     * 初始化地图（高德3D地图）
     */
    private void initMap() {
        if (aMap == null)
            aMap = mapView.getMap();
        viewModel.setAMap(aMap);
        /**
         * 设置一些amap的属性
         */
        aMap.getUiSettings().setZoomControlsEnabled(true);//是否可以缩放
        aMap.moveCamera(CameraUpdateFactory.zoomTo(15));//缩放比例
        //地图文字的Z轴指数,设置为2可以将地图底图文字设置在添加的覆盖物之上
        aMap.setMapTextZIndex(2);
        UiSettings uiSettings = aMap.getUiSettings();//地图的UI设置控制器
        uiSettings.setCompassEnabled(false);// 设置指南针是否显示
        uiSettings.setZoomControlsEnabled(false);// 设置缩放按钮是否显示
        uiSettings.setScaleControlsEnabled(true);// 设置比例尺是否显示
        uiSettings.setRotateGesturesEnabled(true);// 设置地图旋转是否可用
        uiSettings.setTiltGesturesEnabled(true);// 设置地图倾斜是否可用
        uiSettings.setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState)，
        //保存地图当前的状态
        mapView.onSaveInstanceState(outState);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mapView.onResume();
    }


    @Override
    protected void onPause() {
        super.onPause();
        mapView.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
    }

    private void setHeight(int dp) {
        ViewGroup.LayoutParams params = mBinding.layoutBehavior.getLayoutParams();
        params.height = ResolutionUtil.dp2px(this, dp);
        mBinding.layoutBehavior.setLayoutParams(params);
    }

    /**
     * 货主同意了某条报价信息，需要刷新页面状态
     */
    public void agreeOfferRefresh() {
        viewModel.getOfferOwnerList(this, false, sourceDetails);
    }

    @Override
    public void onResult(int position) {
        Intent intent = new Intent();
        switch (position) {
            case 0://首页
                intent.putExtra("showPage", "FRAGMENT_MAIN");
                MainActivity.start(this, intent);
                break;
            case 1://消息
                intent.putExtra("showPage", "FRAGMENT_CHAT");
                MainActivity.start(this, intent);
                break;

            case 2://图查
                intent.putExtra("showPage", "FRAGMENT_TUCHA");
                MainActivity.start(this, intent);
//                EventBus.getDefault().postSticky(MenuEvent.make(EventConstant.EVENT_CHANGE_TAB, "物流货运"));
                break;
            case 3://我的
                intent.putExtra("showPage", "FRAGMENT_ME");
                MainActivity.start(this, intent);
                break;
        }
        finish();
    }

    /**
     * 设置 BottomSheetBehavior 的 PeekHeight(探出高度)
     */
    private void setPeekHeight(int height) {
        if (sheetBehavior != null && goodsDetailsCompleted && routeAddressCompleted) {
            sheetBehavior.setPeekHeight(DisplayUtil.convertDpToPixel(getApplicationContext(), height));
        }
    }
}